package model;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

public abstract class Shape {
	
	protected Grid grid;
	
	public abstract void rotate();
	
	public abstract void move();
	
	public abstract Color getColor();

	int x_location;
	int y_location;
	protected char direction = 'L';
	
	public Shape() {
		super();
	}
	
	public void setDirection(char c) {
		direction = c;
	}
	
	public void setLocation(int x, int y) {
		x_location = x;
		y_location = y;
	}
	
	public boolean canMove() {
		int new_x = x_location;
		int new_y = y_location;
		
		switch (direction) {
		case 'S':
			break;
		case 'U':
			new_y = new_y - 1;
			break;
		case 'D':
			new_y = new_x - 1;
			break;
		case 'L':
			new_x = new_x - 1;
			break;
		case 'R':
			new_x = new_x + 1;
			break;
		default:
				throw new Error("Unknown direction: " + direction);
		}
		
		return grid.canMoveTo(new_x, new_y);
	}
	
	public float getX() {
		return x_location;
	}
	
	public float getY() {
		return y_location;
	}
	
	public char getDirection() {
		return direction;
	}
	
	public Grid getGrid() {
		return grid;
	}

}